package com.example.gatewayserver.controller;

import cn.hutool.http.HttpRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.sql.Time;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/demo")
public class DemoController {


    @RequestMapping("/feign")
    public String getFeign(){
        return System.currentTimeMillis() + "";
    }

    @RequestMapping("/get")
    public String get(){
        String body = HttpRequest.get("http://localhost:7010/demo/get").execute().body();
        System.out.println(body);

        return "成功";
    }

    @GetMapping("/hello")
    public Mono<String> hello() {
        Mono<String> hello = Mono.fromSupplier(() -> getHelloStr());
        return hello;
    }

    private String getHelloStr() {
        String body = HttpRequest.get("http://localhost:7010/demo/get").execute().body();
        return body;
    }

}
